package com.chuangke.lowcode.model;

import java.util.List;

/**
 * 业务模型
 *
 * @author admin
 */
public class EntityModel {

    private Class<?> entityClass;// 实体名称

    private List<EntityModel> children;// 子模型

    public static EntityModel of(Class<?> entityClass){
        EntityModel entityModel = new EntityModel();
        return entityModel.entityClass(entityClass);
    }

    public EntityModel child(EntityModel entityModel){
        if (children == null){
            children = new java.util.ArrayList<>();
        }
        children.add(entityModel);
        return this;
    }

    public EntityModel entityClass(Class<?> entityClass) {
        this.entityClass = entityClass;
        return this;
    }

    public String getId() {
        return entityClass.getSimpleName();
    }

    public Class<?> getEntityClass() {
        return entityClass;
    }

    public String getServiceBeanName() {
        return Character.toLowerCase(entityClass.getSimpleName().charAt(0)) + entityClass.getSimpleName().substring(1) + "Dao";
    }

    public List<EntityModel> getChildren() {
        return children;
    }

}
